# -*- coding: utf-8 -*-
__author__ = 'lztkdr'
__date__ = '2020/3/30 9:51'

from matplotlib import pyplot as plt

# 如果要显示中文标题和坐标表示，需要添加以下两行代码
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

"""
假设你知道了列表a中电影分别在2017-09-14(b_14), 2017-09-15(b_15), 2017-09-16(b_16)三天的票房,为了展示列表中电影本身的票房以及同其他电影的数据对比情况,应该如何更加直观的呈现该数据?

a = ["猩球崛起3：终极之战","敦刻尔克","蜘蛛侠：英雄归来","战狼2"]
b_16 = [15746,312,4497,319]
b_15 = [12357,156,2045,168]
b_14 = [2358,399,2358,362]


数据来源: http://www.cbooo.cn/movieday

"""

a = ["猩球崛起3：终极之战", "敦刻尔克", "蜘蛛侠：英雄归来", "战狼2"]
b_16 = [15746, 312, 4497, 319]
b_15 = [12357, 156, 2045, 168]
b_14 = [2358, 399, 2358, 362]

# 设置图形大小
plt.figure(figsize=(20, 8), dpi=80)

#每个条形图错开的距离 = 条形图的距离
bar_width = 0.2

# 绘制x轴的刻度
x_14 = list(range(len(a)))
x_15 = [i + bar_width for i in x_14]
x_16 = [i + bar_width * 2 for i in x_14]
print(x_14)
print(x_15)
print(x_16)

plt.bar(x_14, b_14, width=bar_width, label='2017-09-14')
plt.bar(x_15, b_15, width=bar_width, label='2017-09-15')
plt.bar(x_16, b_16, width=bar_width, label='2017-09-16')

plt.xticks(x_15, a)

plt.legend()

plt.grid(alpha=0.2)

plt.show()
